package Repository

import (
	"fmt"
	"github.com/gogf/gf/frame/g"
	"main/model"
)

//分页排序
func PageOrderDescAll(database string, table string, modelDto interface{}, where string, pagination *model.Pagination) g.List {
	// 分页计算
	offset := (pagination.Page - 1) * pagination.Limit
	var whereIf string
	if where != "" {
		whereIf += where
	}
	list, _ := g.DB(database).Model(table).
		Fields(modelDto).
		Where(whereIf).
		Offset(offset).
		Limit(pagination.Limit).
		Order(pagination.Sort).
		All()
	fmt.Println(`当前的值：`, list.Json())
	return list.List()
}
